package com.vogue.supplymall.match.config;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import com.vogue.supplymall.account.shiro.filter.WholeAuthenticationFilter;
import com.vogue.supplymall.common.domain.tool.MessageSourceUtils;

/**
 * Created by Administrator on 2017-11-27.
 */
@Configuration
@ImportResource(locations = {"classpath:match-context.xml", "classpath:base-context.xml"})
@ComponentScan({"com.vogue.supplymall.account.domain"})
@ComponentScan({"com.vogue.supplymall.shop.domain"})
@ComponentScan({"com.vogue.supplymall.shop.common"})
@ComponentScan({"com.vogue.supplymall.order.domain"})
@ComponentScan({"com.vogue.supplymall.order.common"})
@ComponentScan({"com.vogue.supplymall.upload.domain"})
@ComponentScan({"com.vogue.supplymall.common.domain.tool"})
@ComponentScan({"com.vogue.supplymall.admin.business.domain"})
@ComponentScan({"com.vogue.supplymall.admin.business.common"})
@ComponentScan({"com.vogue.supplymall.entmanagement.domain"})
@ComponentScan({"com.vogue.supplymall.cross.domain"})
@ComponentScan("com.vogue.supplymall.payment.api")
@MapperScan({"com.vogue.supplymall.account.domain.mapper","com.vogue.supplymall.match.domain.mapper","com.vogue.supplymall.shop.domain.mapper"
	,"com.vogue.supplymall.order.domain.mapper","com.vogue.supplymall.upload.domain.mapper","com.vogue.supplymall.admin.business.domain.mapper"
	,"com.vogue.supplymall.admin.business.common"
	,"com.vogue.supplymall.entmanagement.domain.mapper","com.vogue.supplymall.cross.domain.mapper"})
public class MatchConfig extends WebMvcConfigurerAdapter {

//
//    @Override
//    public void addCorsMappings(CorsRegistry registry) {
//        List<String> allowedOrigins = new ArrayList<>();
//        allowedOrigins.add("http://192.168.7.25:8080");
//        String[] objects = allowedOrigins.toArray(new String[allowedOrigins.size()]);
//        // 允许向该服务器提交请求的URI，*表示全部允许
//        registry.addMapping("/**")
//                .allowedOrigins(objects)
//                // 暴露的头信息
//                .exposedHeaders(HttpHeaders.SET_COOKIE);
//    }
	
	@Bean
	public FilterRegistrationBean regAuth(WholeAuthenticationFilter filter) {
	    FilterRegistrationBean registration = new FilterRegistrationBean(filter);
	    registration.setEnabled(false);
	    return registration;
	}
	
	@Bean(name = "messageSourceUtils")
	public MessageSourceUtils messageSourceUtils() {
		return new MessageSourceUtils("i18n/matchmessages");
	}
}
